package com.ajie.slimming.widget;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.ajie.slimming.R;


public class WarnDialog extends BaseDialog{
	protected OnClickListener mOkClickListener;
	protected View mRootView;
	TextView warn_text;
	Button button_01;
	public WarnDialog(Context context) {
		super(context);
		initView();
	}
	
	private void initView() {
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.warn_dialog);
		mRootView = findViewById(R.id.rootView);
//		mRootView.setBackgroundDrawable(new ColorDrawable(0x0000ff00));
		
		
		button_01 =  (Button) findViewById(R.id.button_01);
		button_01.setOnClickListener(this);
		
		warn_text =  (TextView) findViewById(R.id.warn_text);
		
//		
		Window dialogWindow = getWindow();       
		ColorDrawable dw = new ColorDrawable(0x0000ff00);
	    dialogWindow.setBackgroundDrawable(dw);
	    
	    
//	    WindowManager windowManager =  getWindow().getWindowManager();
//	    Display display = windowManager.getDefaultDisplay();
//	    WindowManager.LayoutParams lp = getWindow().getAttributes();
//	    lp.width = (int)(display.getWidth()); //设置宽度
//	    getWindow().setAttributes(lp);
	    
	}
	
	
	public void setOnOKButtonListener(OnClickListener onClickListener) {
		mOkClickListener = onClickListener;
	}
	
	
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.button_01:
			onButtonOK();
			break;
		}
	}
	
	protected void onButtonOK(){
		dismiss();
		if (mOkClickListener != null){
			mOkClickListener.onClick(this, 0);
		}
	}
}
